<?xml version="1.0" encoding="utf-8" ?>
[#include "/WEB-INF/pages/common/taglibs.ftl"]
[#macro _script]
	<script type="text/javascript">
		var base = (function(){
			// 事件绑定
			function _addEventListeners() {
				// 维护
				$('a[act=edit]').unbind('click').click(function(){
					var	id = $(this).parent().attr('tval');
					[@c.url	var="editUrl" value='/manage/Template_edit.action' scope="page"]
						[@c.param name="id" value=""/]
					[/@c.url]
					var	url	= "${editUrl}" + id;
					//$.get(url, {'id':id, 'ajax':'true'}, function(data) {
					//	$('#body').html(data);
					//})
					window.location	= url;
				})
				
				// 删除
				$('a[act=delete]').unbind('click').click(function(){
					var	id = $(this).parent().attr('tval');
					$( "#delete-confirm" ).dialog({
						resizable: false,
						height:160,
						width:260,
						modal: true,
						buttons: {
							"删除":	function() {
								[@c.url	var="backUrl" value='/manage/Template_list.action' scope="page"]
									[@c.param name="currentPage" value="${currentPage}"/]
								[/@c.url]
								[@c.url	var="deleteUrl" value='/manage/Template_delete.action' scope="page"]
									[@c.param name="backUrl" value="${backUrl}"/]
									[@c.param name="id" value=""/]
								[/@c.url]
								window.location	= "${deleteUrl}" + id;
								$( this	).dialog( "close" );
							},
							"取消":	function() {
								$( this	).dialog( "close" );
							}
						}
					});
					$( "#delete:ui-dialog" ).dialog( "destroy" );
					return false;
				})
				
				// Create jqxExpander
				$('.jqxExpander').jqxExpander({	showArrow: false, toggleMode: 'none', height: '500px', theme: base.config.theme	});
			};
			return {
                config: {
                	url : null,
                    theme: null
                },
                init: function () {
                    _addEventListeners();
                }
			}
		}());
		
		$(function(){
			var link = "[@c.url value='/manage/Template_list.action?currentPage=${currentPage}' /]";
			base.config.theme = getTheme();
			base.config.url = link;
            //Initializing the form
			base.init();
		})
	</script>
[/#macro]

[#macro _content]
	<div class="jqxWidget">
		<div class="jqxExpander">
			<div>模板</div>	
			<div>
			<a href="[@c.url value='/manage/Template_create.action'/]" >新建模板</a>
			[@demo.tableDisplayer id="id" renderTo="${renderTo}" ajaxPage="true"  property="templateList" pagesize=4 page="/manage/Template_list.action" name="FreemarkerTable" config="/WEB-INF/component/table/simple.ftl" bundle="messageSource"]
				[@demo.column name="batch" title="批量" innerHtml="\linput type='checkbox' /\g" headerClass="batch" columnClass="span1"/]
				[@demo.column name="id" property="id" title="ID" headerClass="span1" columnClass="span1"/]
				[@demo.column name="name" property="name" title="名称" columnClass="span3"/]
				[@demo.column name="path" property="path" title="路径" columnClass="span6"/]
				[@demo.column name="type" property="type" title="类型" columnClass="span1"/]
				[@demo.column name="enabled" property="enabled" format="可用:禁用" title="启用状态" columnClass="span2"/]
				[@demo.column name="operate" property="id" title="操作" columnClass="span2" innerHtml="\la href='javascript:void(0);' act='edit' \g编辑\l/a\g&nbsp;|&nbsp;\la href='javascript:void(0);' act='delete' \g删除\l/a\g" headerClass="batch"/]
			[/@demo.tableDisplayer]
			</div>
		</div>
	</div>
	<div id="delete-confirm" style="display:none" title="删除模板">
		<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>模板删除后将无法恢复.</p>
		您确认删除吗？
	</div>
[/#macro]

[#if piece==true]
		[@_script /]
		<!--设置提交行为-->
		[#assign act="save" /]
		<!--设置table渲染到指定ID节点-->
		[#assign renderTo="#templateList"]
		[@_content /]
[#else]
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Insert title here</title>
		<meta name="menu" content="AdminMenu"/> 
		<meta name="heading" content="heading"/>
		<style type="text/css">
			.tempate_list {
				height:800px;
			}
		</style>
		[@_script /]
	</head>
	<body id="body" class="tempate_content">
		<div id="templateList" class="tempate_list">
			[@_content /]
		</div>
	</body>
	</html>
[/#if]